﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VOL;
using BLL;
using System.Data.SqlClient;
using System.Data;
namespace WebShoes.Admin
{
    public partial class Default : System.Web.UI.Page
    {
        NguoiQuanLyBL _NguoiQuanLyBL = new NguoiQuanLyBL();  
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["Login"] != null)
            {
                Response.Redirect("~/Admin/NguoiQuanLyManagerForm.aspx");
            }
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = txtUsername.Text;
            string password = txtPass.Text;

            NguoiQuanLy _NguoiQuanLy = new NguoiQuanLy();
            _NguoiQuanLy = _NguoiQuanLyBL.Login(userName, password);
            if (_NguoiQuanLy == null)
            {
                // sai ten truy cap or mật khẩu
                CustomValidator1.IsValid = false;
            }
            else
            {
                // login thành công
                // lưu thông tin người dùng vào session (biến tạm)
                HttpContext.Current.Session["Login"] = _NguoiQuanLy;
                Response.Redirect("~/Admin/NguoiQuanLyManagerForm.aspx");
            }
        }
    }
}